package com.repair.category.controller;

import com.repair.api.category.response.data.CategoryInfo;
import com.repair.base.result.JsonResult;
import com.repair.category.pojo.vo.ServiceCategoryVO;
import com.repair.category.service.ServiceCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 服务类型 前端控制器
 * </p>
 *
 * @author 桂龙
 * @since 2024-10-11
 */
@RestController
@Slf4j
@Api(tags = "服务类型")
@RequestMapping("/serviceCategory")
public class ServiceCategoryController {

    @Autowired
    private ServiceCategoryService serviceCategoryService;

    @ApiOperation("获取所有服务类型")
    @GetMapping("/getAll")
    public JsonResult<List<ServiceCategoryVO>> getAll() {
        log.debug("获取所有服务类型");
        return JsonResult.ok(serviceCategoryService.getAll());
    }

    @ApiOperation("根据id查询服务类型")
    @GetMapping("/select/{id}")
    public JsonResult<CategoryInfo> selectById(@PathVariable("id") Long id){
        log.debug("根据id查询服务类型");
        CategoryInfo categoryInfo =serviceCategoryService.selectById(id);
        return JsonResult.ok(categoryInfo);
    }

}
